package com.funtl.my.shop.web.admin.abstracts;

import com.funtl.my.shop.domain.TbContentCategory;
import com.futl.my.shop.commons.persistence.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * @author tw
 * @version 1.0
 * @date 2020/6/2 19:04
 */
public abstract class AbstractBaseTreeServiceImpl<T extends BaseEntity, D extends BaseTreeDao<T>> implements BaseTreeService<T> {

    @Autowired
    private D dao;

    /**
     * 查询全部数据
     *
     * @return
     */
    @Override
    public List<T> selectAll() {
        return dao.selectAll();
    }

    /**
     * 刪除
     *
     * @param id
     */
    @Override
    public void delete(long id) {
        dao.delete(id);
    }

    /**
     * 根据id刪除
     *
     * @param id
     * @return
     */
    @Override
    public T getById(long id) {
        return dao.getById(id);
    }

    /**
     * 更新
     *
     * @param entity
     */
    @Override
    public void update(T entity) {
        dao.update(entity);
    }

    /**
     * 根据pid查询
     *
     * @param id
     * @return
     */
    @Override
    public List<T> selectByPid(Long id) {
        return dao.selectByPid(id);
    }

    public void insert(T entity) {
        dao.save(entity);
    }

}
